package chapter15;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author : DuJiabao
 * @Date : 2021/3/4 15:17
 * @Project : thinking_in_java
 * @File : null.java
 * @Desc :
 */
public class GenericVarargs {
  public static <T> List<T> makeList(T... args) {
    List<T> result = new ArrayList<>();
    for (T item : args) {
      result.add(item);
    }
    return result;
  }

  public static void main(String[] args) {
    List<Integer> list = makeList(1, 2, 3, 4, 5, 6);
    System.out.println(list);

    List<? extends Serializable> a = makeList(1, "a");
    System.out.println(a);

    List<? extends Number> numbers = makeList(1, 1.0);
    System.out.println(numbers);
  }
}
